package demom5;

class OutClass{
    public int date1=1;
    private int date2=2;
    public static int date3=3;

    //静态内部类
    static class InnerClass{
        public int date4=4;
        private int date5=5;
        public static final int date6=6;

        public void test(){
            OutClass outClass=new OutClass();
            System.out.println(outClass.date1);
            System.out.println(outClass.date2);
            System.out.println(date3);
            System.out.println(date4);
            System.out.println(date6);
            System.out.println("test方法执行了");
//            System.out.println(data1);
        }
    }
}
class OutClass2{
    public int date1=1;
    private int date2=2;
    public static int date3=3;

    //实例内部类
    class InnerClass2{

        public int date1=1000;//如果在实例内部类中也含date1,则后续打印的也是内部类的date1
        public int date4=4;

        private int date5=5;

        public static final int date6=6;

        public void test(){
            OutClass2 outClass2=new OutClass2();
            System.out.println(outClass2.date1);
            System.out.println(OutClass2.this.date1);
            System.out.println(date1);
            System.out.println(date2);
            System.out.println(date3);
            System.out.println(date4);
            System.out.println(date5);
            System.out.println(date6);
            System.out.println("test方法执行了");
        }
    }
}

class Out{
    public void test1(){
        System.out.println("haha");
    }
}

interface IA{
    void test1();
}
public class Test {

    public static void main(String[] args) {
        //这个类实现了IA 接口 并且重写了test1这个方法
        IA a=new IA(){
            @Override
            public void test1() {
                System.out.println("hahahaha");
            }
        };
//        new Out(){
//
//        }.test1();

//        new Out(){
//            @Override
//            public void test1() {
//                System.out.println("heihei");
//            }
//        }.test1();
    }
    public void testMethod(){
        //局部内部类
        class Inner{
            public int date1;

            public void func(){
                System.out.println("func");
            }
        }
        Inner inner=new Inner();
        inner.func();
    }

    public static void main3(String[] args) {
        //如何实例化一个实例实例内部类对象
        OutClass2 outClass2 =new OutClass2();
        OutClass2.InnerClass2 innerClass2=outClass2.new InnerClass2();
        innerClass2.test();
    }
    public static void main1(String[] args) {
        //如何实例化一个静态内部类对象
        //InnerClass innerclass=new InnerClass();这样是不行的

        OutClass.InnerClass innerClass=new OutClass.InnerClass();//正确的实例化静态内部类的对象
        innerClass.test();
    }
}
